package cn.iocoder.yudao.module.wine.controller.app.supplytype;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wine.controller.admin.supplytype.vo.SupplyTypeRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.supplytype.SupplyTypeDO;
import cn.iocoder.yudao.module.wine.service.supplytype.SupplyTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "app - 酒类类型")
@RestController
@RequestMapping("/wine/supply-type")
@Validated
public class AppSupplyTypeController {

    @Resource
    private SupplyTypeService supplyTypeService;

    @GetMapping("/list")
    @Operation(summary = "获得酒类类型列表 (发布建议或供求信息时使用)")
    public CommonResult<List<SupplyTypeRespVO>> getSupplyTypeList() {
        List<SupplyTypeDO> list = supplyTypeService.appSelectTypeList();
        return success(BeanUtils.toBean(list, SupplyTypeRespVO.class));
    }

    @GetMapping("/by-odor-type-list")
    @Operation(summary = "根据香型获得酒类类型列表")
    public CommonResult<List<SupplyTypeRespVO>> getSupplyTypeListByOdorType(@RequestParam("odorTypeValue") Integer odorTypeValue) {
        List<SupplyTypeDO> list = supplyTypeService.getSupplyTypeListByOdorType(odorTypeValue);
        return success(BeanUtils.toBean(list, SupplyTypeRespVO.class));
    }
}
